package com.ruoyi.jiuzai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiuzai.domain.Baofeimingxi;
import com.ruoyi.jiuzai.service.IBaofeimingxiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物资报废和回收中间表Controller
 * 
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/jiuzai/baofeimingxi")
public class BaofeimingxiController extends BaseController
{
    @Autowired
    private IBaofeimingxiService baofeimingxiService;

    /**
     * 查询物资报废和回收中间表列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:baofeimingxi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Baofeimingxi baofeimingxi)
    {
        startPage();
        List<Baofeimingxi> list = baofeimingxiService.selectBaofeimingxiList(baofeimingxi);
        return getDataTable(list);
    }

    /**
     * 导出物资报废和回收中间表列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:baofeimingxi:export')")
    @Log(title = "物资报废和回收中间表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Baofeimingxi baofeimingxi)
    {
        List<Baofeimingxi> list = baofeimingxiService.selectBaofeimingxiList(baofeimingxi);
        ExcelUtil<Baofeimingxi> util = new ExcelUtil<Baofeimingxi>(Baofeimingxi.class);
        util.exportExcel(response, list, "物资报废和回收中间表数据");
    }

    /**
     * 获取物资报废和回收中间表详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:baofeimingxi:query')")
    @GetMapping(value = "/{baomingId}")
    public AjaxResult getInfo(@PathVariable("baomingId") Long baomingId)
    {
        return success(baofeimingxiService.selectBaofeimingxiByBaomingId(baomingId));
    }

    /**
     * 新增物资报废和回收中间表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:baofeimingxi:add')")
    @Log(title = "物资报废和回收中间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Baofeimingxi baofeimingxi)
    {
        return toAjax(baofeimingxiService.insertBaofeimingxi(baofeimingxi));
    }

    /**
     * 修改物资报废和回收中间表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:baofeimingxi:edit')")
    @Log(title = "物资报废和回收中间表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Baofeimingxi baofeimingxi)
    {
        return toAjax(baofeimingxiService.updateBaofeimingxi(baofeimingxi));
    }

    /**
     * 删除物资报废和回收中间表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:baofeimingxi:remove')")
    @Log(title = "物资报废和回收中间表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baomingIds}")
    public AjaxResult remove(@PathVariable Long[] baomingIds)
    {
        return toAjax(baofeimingxiService.deleteBaofeimingxiByBaomingIds(baomingIds));
    }
}
